var logistRecordCtrl  = new XFApp.client();
$.views.converters({
	
	fauditStatus : function(value) {
		
		if(!value){
			return "";
		}
		for(index in auditStates){
			var auditState = auditStates[index];
			if(auditState.dictCode == value){
				return auditState.dictName;
			}
		}
		return  "未知类型("+value+")";
	},	
	
});

XFApp.client.prototype.logistRecord = {
		successCode : 10000,	
		logistRecordPage : null,
		urlItems : {
			initListURL: basePath+"/userCenter/logisticsRecord/load",
			delURL: basePath+"/userCenter/logisticsRecord/updateOrDelete",
		},
		
		deleteRecord:function(id){
			
			 var type = $("#delRecord").attr("title");
			
			 webAlert({
	                title:'提示',
	                content:'确认执行'+type+'操作吗?',
	                opacity:.5,
	                bg:"gray",
	                width:300,
	                height:10,
	                button:[
	                        {
	                        name:"确定",
	                        callback:function(){
	                        	_this.delConfirm(id);
	                        	this.close();
	                        }
	                        },{
	                        name:"取消",
	                        callback:function(){
	                      	  this.close();
	                        }
	                        }]
	             });
		},
		
		delConfirm: function(id){
			
			var params = {	
            		id : id ,
            		isRemoved:1 //1-逻辑删除
			}
	    	
	    	$.ajax({
	    		url :_this.urlItems.delURL,
	    		data : params,
	    		dataType : "json",
	    		type : 'post',
	    		success : function(data) {				
	    			if(data.code==_this.successCode){ 
	    				window.webDialogUtil.alert("提示",data.msg);	    				
	    				//刷新
	    				_this.load();	    				
				    	        		
	    			}else{
	    				window.webDialogUtil.alert("提示",data.msg);
	    			}
	    		}
	    	});			
			
		},
		
		event : function (){			
			_this = this;
			$("#searchButton").on("click",function(){
				_this.load();
			});
		},	
		
		load : function (){		
            _this = this;
            logistRecordVo = {
            		customerCode : $("#customerCode").val(),
            		customerName : $("#customerName").val()
    		};
			if(!!_this.logistRecordPage){
				_this.logistRecordPage.page("remote",0,logistRecordVo);
			}else{
				_this.logistRecordPage = $("#page").page({
				pageSize : 10,
				remote: {
					url: _this.urlItems.initListURL,
			        params: logistRecordVo, 
			        success: function (data, pageIndex) {
			        	if(data.code==_this.successCode){
			        		if(null == data.result 
										|| null == data.result.itemList
											|| data.result.itemList.length < 1){
			        			$("#page_grid").html('<tr><td align="center" colspan="11">暂无数据</td></tr>');
			        		}else{
			        			$("#page_grid").html($("#pageTmp").render(data.result.itemList));
			        		}
			        		
			        	}else{
			        		  window.webDialogUtil.alert("提示",data.msg);
			        	}
			        },
			        error : function(){
			        	window.webDialogUtil.alert("提示",data.msg);
			        }
				},
				firstBtnText : '首页',
				lastBtnText : '尾页',
				prevBtnText : '上一页',
				nextBtnText : '下一页',
				showInfo : true,
				showJump : true,
				jumpBtnText : '跳转',
				showPageSizes : true,
				infoFormat : '共{pageCount}页'
			});	
		   }			
		},
		
},

$(function(){	
	logistRecordCtrl.logistRecord.load();
	logistRecordCtrl.logistRecord.event();
	
});